package com.aaa.java11;

import java.util.Date;
import java.util.Random;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/16 14:04
 * @description：
 * @modified By：
 * @version:
 */
public class Student {
   private int	id;
    private String	name;
    private  int age;
    private  Date birthday;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", birthday=" + birthday +
                '}';
    }

    public static void main(String[] args) {
        Student[] students= new Student[5];
        for (int i = 0; i < 5; i++) {
            Student student= new Student();
            student.setId(i+1000);
            student.setName("张三"+i);
            student.setAge(new Random().nextInt(100));
            students[i]=student;
        }
        System.out.println("排序之前：");
        for (Student student : students) {
            System.out.println(student);
        }
        for (int i = 1; i <students.length ; i++) {
            for (int j = 0; j < students.length - i; j++) {
                if(students[j].getAge()>students[j+1].getAge()){
                    Student temp= new Student();
                    temp=students[j];
                    students[j]=students[j+1];
                    students[j+1]=temp;
                }
            }
        }
        System.out.println("排除之后：");
        for (Student student : students) {
            System.out.println(student);
        }
    }

}
